package njClass.mvc.core
{
	import flash.events.EventDispatcher;

	public class Proxy extends EventDispatcher
	{
		private static var ProxysArray:Array=new Array();
		protected var Name:String;
		protected var Data:Array=new Array();
		protected var DataClass:Class;
		
		public function Proxy(_Name:String="",_Proxy:Proxy=null,_target:Class=null)
		{
			Name=_Name;
			DataClass=_target;
			ProxysArray.push({"NAME":Name,"PROXY":_Proxy,"CLASS":DataClass});
		}
		
		public static function getProxyByName(string:String):Proxy{
			for(var i:* in ProxysArray){
				if(ProxysArray[i]["NAME"]==string){
					return ProxysArray[i]["PROXY"];
				}
			}
			return null;
		}
		
		public function get ProxyName():String{
			return Name;
		}
		
		public function get ProxyClass():Class{
			return DataClass;
		}
		
		protected function inputData(_data:Object):int{
			Data.push(_data);
			return Data.length;
		}
		
		protected function deleteData(_data:Object):Boolean{
			var tempArray:Array=new Array();
			var isdeled:Boolean=false;
			for(var i:* in Data){
				if(Data[i]!=_data){
					tempArray.push(Data[i]);
					isdeled=true;
				}
			}
			Data=tempArray;
			return isdeled;
		}
	}
}